package cn.hrlly.tao2shou.presenter;

import cn.hrlly.tao2shou.biz.EditRequireBiz;
import cn.hrlly.tao2shou.biz.EditRequireBizImpl;
import cn.hrlly.tao2shou.domain.Require;
import cn.hrlly.tao2shou.listener.OnEditRequireListener;
import cn.hrlly.tao2shou.view.view_interface.EditRequireView;

/**
 * User: gengliang
 * Date: 2016-01-30
 * Time: 15:59
 */

public class EditRequirePresenterImpl implements EditRequirePresenter,OnEditRequireListener {

    private EditRequireBiz editRequireBiz;
    private EditRequireView editRequireView;

    public EditRequirePresenterImpl(EditRequireView editRequireView){
        this.editRequireBiz=new EditRequireBizImpl(this);
        this.editRequireView=editRequireView;
    }

    @Override
    public void alterRequire() {
        Require require=new Require();
        require.setRequireId(editRequireView.getRequireId());
        require.setRequireTitle(editRequireView.getRequireTitle());
        require.setRequireDescription(editRequireView.getRequireDescription());
        require.setAcceptablePrice(editRequireView.getAcceptablePrice());
        editRequireBiz.alterRequire(require);
    }

    @Override
    public void deleteRequire() {
        Require require=new Require();
        require.setRequireId(editRequireView.getRequireId());
        editRequireBiz.deleteRequire(require);
    }

    @Override
    public void editRequireSucc(String message) {
        editRequireView.showMessage(message);
        editRequireView.finishActivity();
    }

    @Override
    public void editRequireSucc(int message) {
        editRequireView.showMessage(message);
        editRequireView.finishActivity();
    }

    @Override
    public void editRequireFail(String errorMessage) {
        editRequireView.showMessage(errorMessage);
    }

    @Override
    public void editRequireFail(int errorMessage) {
        editRequireView.showMessage(errorMessage);
    }
}
